Skip to content

added basic edit functionality#111

Merged
lervag merged 3 commits intolervag:masterfrom
oddish3:make-edit-command
Mar 2, 2025
Merged

added basic edit functionality#111
lervag merged 3 commits intolervag:masterfrom
oddish3:make-edit-command

Conversation

@oddish3
Copy link
Copy Markdown
Contributor

@oddish3 oddish3 commented Feb 26, 2025

This PR adds a new 'edit' command that allows users to directly edit notes matching a query without going through the interactive review interface.

Features:

  • Simple query syntax matching the standard Anki search format
  • Safety check to prevent accidental editing of multiple notes
  • Force multiple option (-f/--force-multiple) to edit multiple notes sequentially

The command provides a more efficient workflow for users who know exactly which notes they want to modify.

TODO:
Consider implementing a feature to display the first few matches
when multiple notes are found.

@lervag
Copy link
Copy Markdown
Owner

lervag commented Mar 1, 2025

This PR adds a new 'edit' command that allows users to directly edit notes matching a query without going through the interactive review interface.

Great, thanks for contributing!

Features: …

I think the feature set looks good.

The command provides a more efficient workflow for users who know exactly which notes they want to modify.

TODO: Consider implementing a feature to display the first few matches when multiple notes are found.

We have the apy list command. I think it would make sense to have the query styles match between the different commands, because then one could use apy list QUERY to inspect that the query is correct before doing apy edit QUERY. Not sure if this is in line with what you've done yet.

@lervag
Copy link
Copy Markdown
Owner

lervag commented Mar 1, 2025

I think this is definitely close to good enough, thanks! I would suggest that we do not list the cards on multiple matches, but instead hint to the apy list command.

The pipeline fails because you didn't apply the formatting. You can use uv run black . locally to fix that.

@oddish3
Copy link
Copy Markdown
Contributor Author

oddish3 commented Mar 1, 2025

Hey!

Yes thanks for looking at this and sorry for the force push (will open another PR for update from file) and the pipeline failing.
I had looked into this further (before I saw the latest) and I have the following in this commit:

[I] ~/r/p/apy ❯❯❯ apy edit "economic evaluation"                                                                                     make-edit-command ✱ ◼
Query matched 8 notes.

First few matching notes:
1. nid:1736869244512 - what do economic evaluations present in terms of a...
2. nid:1736869368131 - What are the two main normative frameworks for the...
3. nid:1738241624995 - what are the 2 major components of economic evalua...
4. nid:1736869610152 - what type of economic evaluation is extra welfaris...
5. nid:1736869282573 - why does implementing economic evaluation pose pro...
...and 3 more notes

Use --force-multiple to edit them all, or refine your query.

Let me know what you think!

@lervag
Copy link
Copy Markdown
Owner

lervag commented Mar 1, 2025

Yes thanks for looking at this and sorry for the force push (will open another PR for update from file) and the pipeline failing.

I really don't mind force pushing, so don't worry about that! I force push on my branches all the time and I can easily handle hard resets when necessary.

I had looked into this further (before I saw the latest) and I have the following in this commit: …

Let me know what you think!

I think it looks good. Perhaps we could adjust it slightly to give the following output instead?

Query matched 8 notes. The first five:

1. nid:1736869244512 - what do economic evaluations present in terms of a...
2. nid:1736869368131 - What are the two main normative frameworks for the...
3. nid:1738241624995 - what are the 2 major components of economic evalua...
4. nid:1736869610152 - what type of economic evaluation is extra welfaris...
5. nid:1736869282573 - why does implementing economic evaluation pose pro...

Hints:
* Use apy edit --force-multiple to edit all matches or refine your query so it only matches a single note.
* Use apy list QUERY to view all matches.

Implements a new feature to update existing notes from Markdown files by
specifying note ID (nid) or card ID (cid). Also fixes tag handling to properly
merge global and note-specific tags.
@lervag lervag merged commit 9452a3f into lervag:master Mar 2, 2025
7 checks passed
@lervag
Copy link
Copy Markdown
Owner

lervag commented Mar 2, 2025

Thanks, this looked good to me, so I merged it. Appreciate your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants